package com.guohengspace.mq.common;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName ResponseResult
 * @Description 结果返回集
 * @Author GuanNing
 * @Date 2022/10/26 16:02
 */
//@Data
//@AllArgsConstructor
//@NoArgsConstructor
public class ResponseResult<T>{

    private static final Integer SUCCESS = 0;

    private static final Integer FAIL = 1;

    private Integer code;

    private String message;

    private T data;

    public ResponseResult(Integer code) {
        this.code = code;
    }

    public ResponseResult(Integer code, String message) {
        super();
        this.code = code;
        this.message = message;
    }

    public ResponseResult(Integer code, String message, T object) {
        this.code = code;
        this.message = message;
        this.data = object;

    }

    public static <T> ResponseResult<T> ok(T object) {
        return new ResponseResult<T>(SUCCESS, "", object);
    }

    public static <T> ResponseResult<T> ok() {
        return new ResponseResult<T>(SUCCESS);
    }

    public static <T> ResponseResult<T> nok(String message) {
        return new ResponseResult<T>(FAIL, message);
    }

    public static <T> ResponseResult<T> nok() {
        return new ResponseResult<T>(FAIL);
    }

    public static <T> ResponseResult<T> nok(Integer code, String message) {
        return new ResponseResult<T>(code, message);
    }

    public static <T> ResponseResult<T> nok(Integer code, String message, T object) {
        return new ResponseResult<T>(code, message, object);
    }

    public static Integer getSUCCESS() {
        return SUCCESS;
    }

    public static Integer getFAIL() {
        return FAIL;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
